<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <!-- <el-form-item label="图片" prop="picUrl"> 
        <el-input
          v-model="queryParams.picUrl"
          placeholder="请输入图片"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->

      <el-form-item label="进出仓单号" prop="transactionOrderNumber">
        <el-input
          v-model="queryParams.transactionOrderNumber"
          placeholder="请输入进出仓单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预约单号" prop="appointmentOrderNumber">
        <el-input
          v-model="queryParams.appointmentOrderNumber"
          placeholder="请输入预约单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="关联单号" prop="relatedOrderNumber">
        <el-input
          v-model="queryParams.relatedOrderNumber"
          placeholder="请输入关联单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="进出仓日期" prop="transactionDate">
        <el-date-picker
          clearable
          v-model="queryParams.transactionDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择进出仓日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="明细创建日期" prop="detailCreateDate">
          <el-date-picker
            clearable
            v-model="queryParams.detailCreateDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择明细创建日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input
            v-model="queryParams.creator"
            placeholder="请输入创建人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品编号" prop="productCode">
          <el-input
            v-model="queryParams.productCode"
            placeholder="请输入商品编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="queryParams.supplierProductCode"
            placeholder="选择供应商商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商商品款号" prop="supplierStyleNumber">
          <el-input
            v-model="queryParams.supplierStyleNumber"
            placeholder="选择供应商商品款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="款号" prop="styleNumber">
          <el-input
            v-model="queryParams.styleNumber"
            placeholder="请输入款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="颜色尺码" prop="proColorSize">
          <el-input
            v-model="queryParams.proColorSize"
            placeholder="请输入颜色尺码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input
            v-model="queryParams.brand"
            placeholder="请输入品牌"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="虚拟分类" prop="virtualCategory">
          <el-input
            v-model="queryParams.virtualCategory"
            placeholder="请输入虚拟分类"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="产品分类" prop="productCategory">
          <el-input
            v-model="queryParams.productCategory"
            placeholder="请输入产品分类"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="仓储方" prop="storageParty">
          <el-input
            v-model="queryParams.storageParty"
            placeholder="请输入仓储方"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="仓库名称" prop="warehouseName">
          <el-input
            v-model="queryParams.warehouseName"
            placeholder="请输入仓库名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input
            v-model="queryParams.quantity"
            placeholder="请输入数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="关联仓储方" prop="relatedStorageParty">
          <el-input
            v-model="queryParams.relatedStorageParty"
            placeholder="请输入关联仓储方"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="关联仓库" prop="relatedWarehouseName">
          <el-input
            v-model="queryParams.relatedWarehouseName"
            placeholder="请输入关联仓库"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="市场吊牌价" prop="marketPrice">
          <el-input
            v-model="queryParams.marketPrice"
            placeholder="请输入市场吊牌价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="售后单号" prop="afterSalesOrderNumber">
          <el-input
            v-model="queryParams.afterSalesOrderNumber"
            placeholder="请输入售后单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="线上订单号" prop="onlineOrderNumber">
          <el-input
            v-model="queryParams.onlineOrderNumber"
            placeholder="请输入线上订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品重量" prop="productWeight">
          <el-input
            v-model="queryParams.productWeight"
            placeholder="请输入商品重量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品体积" prop="productVolume">
          <el-input
            v-model="queryParams.productVolume"
            placeholder="请输入商品体积"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单位" prop="pUnit">
          <el-input
            v-model="queryParams.pUnit"
            placeholder="请输入单位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['financial:BiSaleOutWarehouse:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['financial:BiSaleOutWarehouse:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['financial:BiSaleOutWarehouse:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['financial:BiSaleOutWarehouse:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      :height="630"
      v-loading="loading"
      :data="BiSaleOutWarehouseList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        width="120"
        label="销售出仓数据id"
        align="center"
        prop="id"
      />
      <el-table-column width="120" label="图片" align="center" prop="picUrl">
        <template #default="scope">
          <el-popover
            effect="light"
            trigger="click"
            placement="right"
            width="auto"
            v-if="scope.row.picUrl"
          >
            <template #default>
              <img
                :src="pjtUrl + scope.row.picUrl"
                style="width: 800px; height: 600px; object-fit: contain"
                lazy
              />
            </template>
            <template #reference>
              <img
                :src="pjtUrl + scope.row.picUrl"
                style="object-fit: contain; width: 20px; height: 20px"
                lazy
              />
            </template>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="进出仓单号"
        align="center"
        prop="transactionOrderNumber"
      />
      <el-table-column
        width="120"
        label="预约单号"
        align="center"
        prop="appointmentOrderNumber"
      />
      <el-table-column
        width="120"
        label="关联单号"
        align="center"
        prop="relatedOrderNumber"
      />
      <el-table-column
        width="120"
        label="进出仓日期"
        align="center"
        prop="transactionDate"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.transactionDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="明细创建日期"
        align="center"
        prop="detailCreateDate"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.detailCreateDate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="创建人"
        align="center"
        prop="creator"
      />
      <el-table-column
        width="120"
        label="商品编号"
        align="center"
        prop="productCode"
      />
      <el-table-column
        width="120"
        label="供应商商品编码"
        align="center"
        prop="supplierProductCode"
      />
      <el-table-column
        width="120"
        label="供应商商品款号"
        align="center"
        prop="supplierStyleNumber"
      />
      <el-table-column
        width="120"
        label="款号"
        align="center"
        prop="styleNumber"
      />
      <el-table-column
        width="120"
        label="颜色尺码"
        align="center"
        prop="proColorSize"
      />
      <el-table-column width="120" label="品牌" align="center" prop="brand" />
      <el-table-column
        width="120"
        label="虚拟分类"
        align="center"
        prop="virtualCategory"
      />
      <el-table-column
        width="120"
        label="产品分类"
        align="center"
        prop="productCategory"
      />
      <el-table-column
        width="120"
        label="进出仓类型"
        align="center"
        prop="transactionType"
      />
      <el-table-column
        width="120"
        label="仓储方"
        align="center"
        prop="storageParty"
      />
      <el-table-column
        width="120"
        label="仓库名称"
        align="center"
        prop="warehouseName"
      />
      <el-table-column
        width="120"
        label="数量"
        align="center"
        prop="quantity"
      />
      <el-table-column
        width="120"
        label="关联仓储方"
        align="center"
        prop="relatedStorageParty"
      />
      <el-table-column
        width="120"
        label="关联仓库"
        align="center"
        prop="relatedWarehouseName"
      />
      <el-table-column width="120" label="备注" align="center" prop="remarks" />
      <el-table-column
        width="120"
        label="明细行备注"
        align="center"
        prop="detailRemarks"
      />
      <el-table-column
        width="120"
        label="订单类型"
        align="center"
        prop="orderType"
      />
      <el-table-column
        width="120"
        label="市场吊牌价"
        align="center"
        prop="marketPrice"
      />
      <el-table-column
        width="120"
        label="售后单号"
        align="center"
        prop="afterSalesOrderNumber"
      />
      <el-table-column
        width="180"
        label="线上订单号"
        align="center"
        prop="onlineOrderNumber"
      />
      <el-table-column
        width="120"
        label="商品重量"
        align="center"
        prop="productWeight"
      />
      <el-table-column
        width="120"
        label="商品体积"
        align="center"
        prop="productVolume"
      />
      <el-table-column width="120" label="单位" align="center" prop="pUnit" />
      <el-table-column
        width="120"
        label="出仓类型"
        align="center"
        prop="outboundType"
      />
      <el-table-column
        width="120"
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['financial:BiSaleOutWarehouse:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['financial:BiSaleOutWarehouse:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改销售出仓数据对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="图片" prop="picUrl">
          <el-input v-model="form.picUrl" placeholder="请输入图片" />
        </el-form-item>
        <el-form-item label="进出仓单号" prop="transactionOrderNumber">
          <el-input
            v-model="form.transactionOrderNumber"
            placeholder="请输入进出仓单号"
          />
        </el-form-item>
        <el-form-item label="预约单号" prop="appointmentOrderNumber">
          <el-input
            v-model="form.appointmentOrderNumber"
            placeholder="请输入预约单号"
          />
        </el-form-item>
        <el-form-item label="关联单号" prop="relatedOrderNumber">
          <el-input
            v-model="form.relatedOrderNumber"
            placeholder="请输入关联单号"
          />
        </el-form-item>
        <el-form-item label="进出仓日期" prop="transactionDate">
          <el-date-picker
            clearable
            v-model="form.transactionDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择进出仓日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="明细创建日期" prop="detailCreateDate">
          <el-date-picker
            clearable
            v-model="form.detailCreateDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择明细创建日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input v-model="form.creator" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="商品编号" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入商品编号" />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="form.supplierProductCode"
            placeholder="选择供应商商品编码"
          />
        </el-form-item>
        <el-form-item label="供应商商品款号" prop="supplierStyleNumber">
          <el-input
            v-model="form.supplierStyleNumber"
            placeholder="选择供应商商品款号"
          />
        </el-form-item>
        <el-form-item label="款号" prop="styleNumber">
          <el-input v-model="form.styleNumber" placeholder="请输入款号" />
        </el-form-item>
        <el-form-item label="颜色尺码" prop="proColorSize">
          <el-input v-model="form.proColorSize" placeholder="请输入颜色尺码" />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="虚拟分类" prop="virtualCategory">
          <el-input
            v-model="form.virtualCategory"
            placeholder="请输入虚拟分类"
          />
        </el-form-item>
        <el-form-item label="产品分类" prop="productCategory">
          <el-input
            v-model="form.productCategory"
            placeholder="请输入产品分类"
          />
        </el-form-item>
        <el-form-item label="仓储方" prop="storageParty">
          <el-input v-model="form.storageParty" placeholder="请输入仓储方" />
        </el-form-item>
        <el-form-item label="仓库名称" prop="warehouseName">
          <el-input v-model="form.warehouseName" placeholder="请输入仓库名称" />
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form.quantity" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="关联仓储方" prop="relatedStorageParty">
          <el-input
            v-model="form.relatedStorageParty"
            placeholder="请输入关联仓储方"
          />
        </el-form-item>
        <el-form-item label="关联仓库" prop="relatedWarehouseName">
          <el-input
            v-model="form.relatedWarehouseName"
            placeholder="请输入关联仓库"
          />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input
            v-model="form.remarks"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="明细行备注" prop="detailRemarks">
          <el-input
            v-model="form.detailRemarks"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="市场吊牌价" prop="marketPrice">
          <el-input v-model="form.marketPrice" placeholder="请输入市场吊牌价" />
        </el-form-item>
        <el-form-item label="售后单号" prop="afterSalesOrderNumber">
          <el-input
            v-model="form.afterSalesOrderNumber"
            placeholder="请输入售后单号"
          />
        </el-form-item>
        <el-form-item label="线上订单号" prop="onlineOrderNumber">
          <el-input
            v-model="form.onlineOrderNumber"
            placeholder="请输入线上订单号"
          />
        </el-form-item>
        <el-form-item label="商品重量" prop="productWeight">
          <el-input v-model="form.productWeight" placeholder="请输入商品重量" />
        </el-form-item>
        <el-form-item label="商品体积" prop="productVolume">
          <el-input v-model="form.productVolume" placeholder="请输入商品体积" />
        </el-form-item>
        <el-form-item label="单位" prop="pUnit">
          <el-input v-model="form.pUnit" placeholder="请输入单位" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="500px"
      append-to-body
      v-if="dialogVisible"
    >
      <el-upload
        :action="Upload.url"
        :headers="Upload.headers"
        :limit="limit"
        :on-exceed="handleExceed"
        :on-success="handlePictureSuccessPic"
        :before-upload="beforeAvatarUpload"
        :on-preview="handlePictureCardPreview"
        :file-list="fileLi"
        :on-change="changeFile1"
      >
        <el-button size="small" type="primary">导入文件</el-button>
        <!-- <i class="el-icon-plus"></i> -->
      </el-upload>
    </el-dialog>
  </div>
</template>

<script>
import {
  listBiSaleOutWarehouse,
  getBiSaleOutWarehouse,
  delBiSaleOutWarehouse,
  addBiSaleOutWarehouse,
  updateBiSaleOutWarehouse,
} from "@/api/Warehouse/BiSaleOutWarehouse";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "BiSaleOutWarehouse",
  data() {
    return {
      pjtUrl: process.env.VUE_APP_BASE_API,

      fileLi: [],
      file: "",
      dialogVisible: false,
      // 图片数量限制
      limit: 2,
      Upload: {
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url:
          process.env.VUE_APP_BASE_API +
          "/financial/BiSaleOutWarehouse/importData",
      },
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 销售出仓数据表格数据
      BiSaleOutWarehouseList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        picUrl: null,
        transactionOrderNumber: null,
        appointmentOrderNumber: null,
        relatedOrderNumber: null,
        transactionDate: null,
        detailCreateDate: null,
        creator: null,
        productCode: null,
        supplierProductCode: null,
        supplierStyleNumber: null,
        styleNumber: null,
        proColorSize: null,
        brand: null,
        virtualCategory: null,
        productCategory: null,
        transactionType: null,
        storageParty: null,
        warehouseName: null,
        quantity: null,
        relatedStorageParty: null,
        relatedWarehouseName: null,
        remarks: null,
        detailRemarks: null,
        orderType: null,
        marketPrice: null,
        afterSalesOrderNumber: null,
        onlineOrderNumber: null,
        productWeight: null,
        productVolume: null,
        pUnit: null,
        outboundType: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询销售出仓数据列表 */
    getList() {
      this.loading = true;
      listBiSaleOutWarehouse(this.queryParams).then((response) => {
        this.BiSaleOutWarehouseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        picUrl: null,
        transactionOrderNumber: null,
        appointmentOrderNumber: null,
        relatedOrderNumber: null,
        transactionDate: null,
        detailCreateDate: null,
        creator: null,
        productCode: null,
        supplierProductCode: null,
        supplierStyleNumber: null,
        styleNumber: null,
        proColorSize: null,
        brand: null,
        virtualCategory: null,
        productCategory: null,
        transactionType: null,
        storageParty: null,
        warehouseName: null,
        quantity: null,
        relatedStorageParty: null,
        relatedWarehouseName: null,
        remarks: null,
        detailRemarks: null,
        orderType: null,
        marketPrice: null,
        afterSalesOrderNumber: null,
        onlineOrderNumber: null,
        productWeight: null,
        productVolume: null,
        pUnit: null,
        outboundType: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加销售出仓数据";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getBiSaleOutWarehouse(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改销售出仓数据";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateBiSaleOutWarehouse(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBiSaleOutWarehouse(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除销售出仓数据编号为"' + ids + '"的数据项？')
        .then(function () {
          return delBiSaleOutWarehouse(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "financial/BiSaleOutWarehouse/export",
        {
          ...this.queryParams,
        },
        `BiSaleOutWarehouse_${new Date().getTime()}.xlsx`
      );
    },
    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    // 打开加载层
    openUploadLoading() {
      this.$modal.loading("正在导入，请稍候！");
    },
    //文件导入成功回传

    handlePictureSuccessPic(res, file) {
      console.log(JSON.stringify(res));
      //设置图片访问路径 （url 后台传过来的的上传地址）
      // this.picUrl = file.response.url;
      // const url = file.response.fileName;
      this.file = file.response.url;
      console.log(JSON.stringify(this.file));
      if (res.code == 200) {
        this.dialogVisible = false;
        this.$modal.closeLoading();
        this.$modal.msgSuccess(res.msg);
        // if (res.msg == "操作成功") {
        //   this.$modal.msgSuccess("导入成功");
        // } else {
        //   this.$modal.msgError(res.msg);
        // }
        this.getList();
        // return true
      } else {
        this.$modal.msgError(res.msg);
        this.dialogVisible = true;
        // this.$message.msgError('该颜色未在字典定义')
        return;
      }
    },
    //图片预览
    handlePictureCardPreview(file) {
      // this.picUrl = file.url
      // this.imageUrl = file.url;
      // this.dialogVisible = true;
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type == 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 100;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 100MB!");
      }
      this.openUploadLoading();
      return isLt2M;
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.fileLi = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
  },
};
</script>
